<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>js利用鼠标onmouseover和onmouseout事件改变颜色</title>
    <style type="text/css">
         div{
             background-color: green;
             color: white;
             width: 200px;
             height: 150px;
             border: 1px red solid;
             padding: 0px;
         }
    </style>
    <script type="text/javascript">
        function changeOver(obj)
        {
            obj.style.backgroundColor="blue";
            obj.innerHTML="请移开鼠标"
        }
        function changeOut(obj)
        {
            obj.style.backgroundColor="green";
            obj.innerHTML="请移入鼠标"
        }
    </script>
</head>
<body>
    <div onmouseover="changeOver(this)" onmouseout="changeOut(this)">
        请单击这里
    </div>
</body>
</html>